<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<style type="text/css">
.hei {
	background-color: gainsboro;
}
.yellow {
	background-color:yellow;
}

a {
	margin-left: 100px;
}
</style>
</head>
<body>
<h3>你好，<h1 id="mz"></h1></h3>
	<div align="center">
		<h1>驾校查询</h1>
		城区：<select id="chengqu">
			<option value="0">请选择</option>
		</select>&nbsp;&nbsp;&nbsp;&nbsp;<button id="selectdq" type="button">查询</button>
		<table align="center" id="xinxi" border="" cellspacing="" cellpadding="">

		</table>
		<div id="page"></div>
	</div>
</body>
<script type="text/javascript" src="/Maven_jiaxiao_war_exploded/js/jquery2.2.4.js"></script>
	<script>
	$.ajax({
		"url":"/Maven_jiaxiao_war_exploded/xiala",
		"type":"get",
		"dataType":"json",
		"success":function(pd){
			for (var i=0;i<pd.length;i++){
				$("#chengqu").append("<option value="+pd[i].id+">"+pd[i].name+"</option>");
			}
		}
	})
	$.ajax({
		"url":"/Maven_jiaxiao_war_exploded/yanzheng",
		"type":"get",
		"dataType":"json",
		"success":function(pd){
			var user = JSON.parse(pd);
			$("#mz").text(user.username)
		}
	})
	fenye(1,null)
	function fenye(curr,chengqu){
		$.ajax({
			"url":"/Maven_jiaxiao_war_exploded/chaxun",
			"type":"get",
			"data":{"page":curr,"id":chengqu},
			"dataType":"json",
			"success":function(pd){
				$("#xinxi").html("")
				$("#xinxi").append("<tr class=\"hei\">\n" +
				"\t\t\t\t<th>驾校名称</th>\n" +
				"\t\t\t\t<th>所在地区</th>\n" +
				"\t\t\t\t<th>地址</th>\n" +
				"\t\t\t\t<th>联系电话</th>\n" +
				"\t\t\t\t<th>操作</th>\n" +
				"\t\t\t</tr>")
				for (var i=0;i<pd[0].length;i++){
					var colorbiaoshi="";
					if(i%2==1){
						colorbiaoshi="yellow"
					}
					$("#xinxi").append("<tr class="+colorbiaoshi+">"+
							"<td>"+pd[0][i].name+"</td>"+
							"<td>"+pd[2][i]+"</td>"+
							"<td>"+pd[0][i].address+"</td>"+
							"<td>"+pd[0][i].phone+"</td>"+
							"<td><a href='/Maven_jiaxiao_war_exploded/Xiugai.html?id="+pd[0][i].id+"&cid="+pd[0][i].cityareaid+"'>修改</a></td>"+
							"</tr>");
				}
				$("#page").html("")
				$("#page").append("<p>一共"+pd[1].pages+"页</p>\n" +
						"<a href='#' onClick='fenye("+pd[1].firstPage+",null)' >第一页</a>\n" +
						"<a href='#' onClick='fenye("+pd[1].prePage+",null)'>上一页</a>\n" +
						"<a href='#' onClick='fenye("+pd[1].nextPage+",null)'>下一页</a>\n" +
						"<a href='#' onClick='fenye("+pd[1].lastPage+",null)'>最后页</a>");
			}
		})
	}
$("#selectdq").click(function (){
	var id=$("#chengqu").val();
	fenye(1,id)
})
</script>
</html>
